package cn.easybuy.service.news;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.easybuy.entity.News;
import cn.easybuy.mapper.NewsMapper;
import cn.easybuy.mapper.OrderMapper;
import cn.easybuy.param.NewsParams;
import cn.easybuy.utils.DataSourceUtil;
import cn.easybuy.utils.Pager;
import cn.easybuy.utils.Params;

/**
 *
 */
@Service
public class NewsServiceImpl implements NewsService {
	@Autowired
	private NewsMapper nm;
	
	
	public void deleteNews(String id) {// 删除新闻
		nm.deleteById(Integer.parseInt(id));
	}

	public News findNewsById(String id) {// 根据ID获取新闻
		News news = null;	
		news = nm.getNewsById(Integer.parseInt(id));
		return news;
	}

	public void addNews(News news) {// 保存新闻
		nm.add(news);
	}

	public void updateNews(News news) {// 更新留言
		nm.update(news);
	}

	
	public List<News> queryNewsPageList(NewsParams param) throws SQLException {
		List<News> newsList=new ArrayList<News>();
		newsList=nm.queryNewsList(param);
		return newsList;
	}
	
	@Override
	public List<News> queryNewsList(NewsParams param) {
		List<News> newsList=new ArrayList<News>();
		newsList=nm.queryNewsList(param);
		return newsList;
	}

	@Override
	public Integer queryNewsCount(NewsParams param) {
		Integer count=0;
		count=nm.queryNewsCount(param);
		return count;
	}

}
